using System;
using System.Diagnostics;

using ObjectRelationalMapping.Configuration;
using ObjectRelationalMapping.Helper;

namespace ObjectRelationalMapping
{
    public class Generator
    {
        public static void Generate ( string projectDirectory )
        {
            Stopwatch stopwatch = new Stopwatch ();
            stopwatch.Start ();

            Common.ProjectDirectory = projectDirectory;

            Settings.Get ();
            Console.WriteLine ( string.Empty );

            Mapper.Generate ();
            Mapper.Class.Generate ();
            Mapper.Database.Generate ();
            Console.WriteLine ( string.Empty );

            Output.Write ();
            Output.Class.Write ();
            Output.Database.Write ();
            Console.WriteLine ( string.Empty );

            Output.Database.Execute ();
            Console.WriteLine ( string.Empty );

            stopwatch.Stop ();
            TimeSpan elapsedTime = stopwatch.Elapsed;
            Console.WriteLine (
                "The object relational mappings were completed in {0:0000}.{1:00} seconds.",
                elapsedTime.Seconds,
                elapsedTime.Milliseconds / 10 );
        }
    }
}